
networks:
  caddy-net:
    driver: bridge
  gitea-net:
    driver: bridge
  immich-net:
    driver: bridge
  navidrome-net:
    driver: bridge
  nextcloud-net:
    driver: bridge
  plex-network:
    driver: bridge

services:
  # Caddy Reverse Proxy
  caddy:
    image: caddy:latest
    container_name: caddy
    restart: unless-stopped
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - ./Caddyfile:/etc/caddy/Caddyfile
      - caddy_data:/data
      - caddy_config:/config
    networks:
      - caddy-net
      - gitea-net
      - immich-net
      - navidrome-net
      - nextcloud-net
      - plex-network

  # Gitea - Code Hosting
  gitea:
    image: gitea/gitea:latest
    container_name: gitea
    restart: unless-stopped
    environment:
      - USER_UID=1000
      - USER_GID=1000
      - DB_TYPE=sqlite3 # Use PostgreSQL for production
    volumes:
      - ./data/gitea:/data
      - /etc/timezone:/etc/timezone:ro
      - /etc/localtime:/etc/localtime:ro
    networks:
      - gitea-net
    deploy:
      resources:
        limits:
          memory: 512M

  # Immich - Photo Gallery
  immich-server:
    container_name: immich_server
    networks:
#      - immich_default # Original network
      - immich-net
  # <-- Add this shared network
    image: ghcr.io/immich-app/immich-server:${IMMICH_VERSION:-release}
    # extends:
    #   file: hwaccel.transcoding.yml
    #   service: cpu # set to one of [nvenc, quicksync, rkmpp, vaapi, vaapi-wsl] for accelerated transcoding
    volumes:
      # Do not edit the next line. If you want to change the media storage location on your system, edit the value of UPLOAD_LOCATION in the .env file
      - ${UPLOAD_LOCATION}:/data
      - /mnt/seagate8TB/photos:/mydata  
      - /etc/localtime:/etc/localtime:ro
    env_file:
      - .env
    ports:
      - '2283:2283'
    depends_on:
      - redis
      - database
    restart: always
    healthcheck:
      disable: false

  immich-machine-learning:
    container_name: immich_machine_learning
    networks:
#      - immich_default # Original network
      - immich-net
  # <-- Add this shared network
    # For hardware acceleration, add one of -[armnn, cuda, rocm, openvino, rknn] to the image tag.
    # Example tag: ${IMMICH_VERSION:-release}-cuda
    image: ghcr.io/immich-app/immich-machine-learning:${IMMICH_VERSION:-release}
    # extends: # uncomment this section for hardware acceleration - see https://immich.app/docs/features/ml-hardware-acceleration
    #   file: hwaccel.ml.yml
    #   service: cpu # set to one of [armnn, cuda, rocm, openvino, openvino-wsl, rknn] for accelerated inference - use the `-wsl` version for WSL2 where applicable
    volumes:
      - model-cache:/cache
    env_file:
      - .env
    restart: always
    healthcheck:
      disable: false

  redis:
    container_name: immich_redis
    networks:
#      - immich_default # Original network
      - immich-net
  # <-- Add this shared network
    image: docker.io/valkey/valkey:8-bookworm@sha256:5b8f8c333bef895c925f56629d6ba90aea95a4f7391f62411e625267c600b19c
    healthcheck:
      test: redis-cli ping || exit 1
    restart: always

  database:
    container_name: immich_postgres
    networks:
#      - immich_default # Original network
      - immich-net
  # <-- Add this shared network
    image: ghcr.io/immich-app/postgres:14-vectorchord0.4.3-pgvectors0.2.0@sha256:32324a2f41df5de9efe1af166b7008c3f55646f8d0e00d9550c16c9822366b4a
    environment:
      POSTGRES_PASSWORD: ${DB_PASSWORD}
      POSTGRES_USER: ${DB_USERNAME}
      POSTGRES_DB: ${DB_DATABASE_NAME}
      POSTGRES_INITDB_ARGS: '--data-checksums'
      # Uncomment the DB_STORAGE_TYPE: 'HDD' var if your database isn't stored on SSDs
      # DB_STORAGE_TYPE: 'HDD'
    volumes:
      # Do not edit the next line. If you want to change the database storage location on your system, edit the value of DB_DATA_LOCATION in the .env file
      - ${DB_DATA_LOCATION}:/var/lib/postgresql/data
    shm_size: 128mb
    restart: always

  # Navidrome - Music Server
  navidrome:
    image: deluan/navidrome:latest
    container_name: navidrome
    restart: unless-stopped
    environment:
      - ND_SCANSCHEDULE=1h
      - ND_LOGLEVEL=info
      - ND_SESSIONTIMEOUT=24h
      - ND_BASEURL=/
    volumes:
      - ./data/navidrome:/data
      - /music:/music # CHANGE THIS
    networks:
      - navidrome-net
    deploy:
      resources:
        limits:
          memory: 512M

  # Nextcloud - File Sync
  nextcloud:
    image: nextcloud:latest
    container_name: nextcloud
    restart: unless-stopped
    environment:
      - NEXTCLOUD_TRUSTED_DOMAINS=files.ccktgp.club # CHANGE THIS
      - APACHE_DISABLE_REWRITE_IP=1
      - OVERWRITEPROTOCOL=https
      - MYSQL_HOST=nextcloud_db
      - MYSQL_DATABASE=nextcloud
      - MYSQL_USER=nextcloud
      - MYSQL_PASSWORD=your_secure_db_password_123
    volumes:
      - ./data/nextcloud:/var/www/html
      - ./data/nextcloud/apps:/var/www/html/custom_apps
      - ./data/nextcloud/config:/var/www/html/config
      - ./data/nextcloud/themes:/var/www/html/themes
    networks:
      - nextcloud-net
    depends_on:
      - nextcloud_db
    deploy:
      resources:
        limits:
          memory: 1G

  # MariaDB Database
  nextcloud_db:
    image: mariadb:10.6
    container_name: nextcloud_db
    restart: always
    environment:
      - MYSQL_ROOT_PASSWORD=your_secure_root_password_123
      - MYSQL_PASSWORD=your_secure_db_password_123
      - MYSQL_DATABASE=nextcloud
      - MYSQL_USER=nextcloud
    volumes:
      - db_data:/var/lib/mysql
      - ./db-backups:/backups
    command: --transaction-isolation=READ-COMMITTED --binlog-format=ROW
    networks:
      - nextcloud-net

  # Plex Media Server
  # plex:
  #  image: lscr.io/linuxserver/plex:latest
  #  container_name: plex
  #  environment:
  #    - PUID=1000
  #    - PGID=1000
  #    - VERSION=docker
  #    - TZ=UTC # Change to your timezone
  #    - ADVERTISE_IP=http://git.ccktgp.club:32400        
  #  volumes:
  #    - ./plex/config:/config
  #    - ./plex/transcode:/transcode
  #    - /path/to/your/media:/data # Change to your media directory
  #  ports:
  #    - "32400:32400" # Expose Plex port internally
  #  networks:
  #    - plex-network
  #  restart: unless-stopped

volumes:
  caddy_data:
  caddy_config:
  gitea_data:
  immich_data:
  navidrome_data:
  nextcloud_data:
  db_data:
  model-cache:

